package com.zzyl.config;

import com.aliyun.iot20180120.Client;
import com.aliyun.teaopenapi.models.Config;
import com.zzyl.properties.AliIoTConfigProperties;
import com.zzyl.properties.AliyunIotProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliyunIotConfig {
    @Bean
    public Client client(AliIoTConfigProperties aliIoTConfigProperties) throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(aliIoTConfigProperties.getAccessKeyId())
                // 您的AccessKey Secret
                .setAccessKeySecret(aliIoTConfigProperties.getAccessKeySecret())
                .setRegionId(aliIoTConfigProperties.getRegionId());
        // 访问的域名
        Client client = new Client(config);
        return client;
    }
}
